import java.util.ArrayList;
import java.util.List;

import bean.Product;


public class No18 {
	private static final Double TAX_RATE = new Double(7)/100;
	private static List<Product> insertProducts = new ArrayList<Product>();
	private static List<Product> updateProducts = new ArrayList<Product>();
	private static List<Product> deleteProducts = new ArrayList<Product>();
	
	private static void initValue() {
		for (int i = 0; i < 3; i++) {
			Product product = new Product();
			product.setProductName("Item " + (i+1));
			product.setProductPrice(new Double((i+1) + "000"));
			product.setStatus("Active");
			product.setTax(product.getProductPrice() * (TAX_RATE));
			
			insertProducts.add(product);
		}
		
		for (int i = 0; i < 3; i++) {
			Product product = new Product();
			product.setProductName("Item " + (i+4));
			product.setProductPrice(new Double((i+1) + "0000"));
			product.setStatus("Active");
			product.setTax(product.getProductPrice() * (TAX_RATE));
			
			updateProducts.add(product);
		}
		
		for (int i = 0; i < 3; i++) {
			Product product = new Product();
			product.setProductName("Item " + (i+7));
			product.setProductPrice(new Double((i+1) + "000"));
			product.setStatus("Inactive");
			product.setTax(product.getProductPrice() * (TAX_RATE));
			
			deleteProducts.add(product);
		}
	}
	
	public static void main(String[] args) {
		initValue();
		List<String> insertScripts = new ArrayList<String>();
		List<String> updateScripts = new ArrayList<String>();
		List<String> deleteScripts = new ArrayList<String>();
		
		for (Product product : insertProducts) {
			String insertScript = String.format("INSERT INTO PRODUCT VALUES('%s', %.2f, '%s', %.2f)", 
					product.getProductName(), product.getProductPrice(), product.getStatus(), product.getTax());
			System.out.println(insertScript);
			insertScripts.add(insertScript);
			
		}
		
		for (Product product : updateProducts) {
			String updateScript = String.format("UPDATE PRODUCT SET NAME = '%s', PRICE = %.2f, STATUS = '%s', TAX = %.2f WHERE NAME = '%s')", 
					product.getProductName(), product.getProductPrice(), product.getStatus(), product.getTax(), product.getProductName());
			System.out.println(updateScript);
			updateScripts.add(updateScript);
			
		}
		
		for (Product product : deleteProducts) {
			String deleteScript = String.format("DELETE FROM PRODUCT WHERE NAME = '%s'", product.getProductName());
			System.out.println(deleteScript);
			deleteScripts.add(deleteScript);
			
		}
		
	}
}
